import fly from "../main"

let modal = 'area'

/**
 * 获取接单地址列表
 * @returns {Promise<{}>}
 */
export async function getOrderAddressList() {
  let response = {}
  await fly.get(`/v2/${modal}`).then((res) => {
    response = res.data
  })
  return response;
}


/**
 * 添加接单地址信息
 * @param data 接单地址数据
 * @returns {Promise<{}>}
 */
export async function addOrderAddress(data) {
  let body = {
    province_id:data[0].code,
    city_id:data[1].code,
    province_name:data[0].name,
    city_name:data[1].name,
  }
  let response = {}
  await fly.post(`/v2/${modal}`, body).then((res) => {
    response = res.data
  })
  return response;
}


/**
 * 删除接单地址信息
 * @param $id 接单地址id
 * @returns {Promise<{}>}
 */
export async function delOrderAddress($id) {
  let response = {}
  await fly.delete(`/v2/${modal}/${$id}`).then((res) => {
    response = res.data
  })
  return response;
}


/**
 * 获取接单地址信息
 * @param $id 接单地址id
 * @returns {Promise<{}>}
 */
export async function getOrderAddress($id) {
  let response = {}
  await fly.get(`/v2/${modal}/${$id}`).then((res) => {
    response = res.data
  })
  return response;
}

/**
 * 更新接单地址信息
 * @param id
 * @param car
 * @returns {Promise<{}>}
 */
export async function updateOrderAddress(id, car) {
  let response = {}
  await fly.put(`/v2/${modal}/${id}`, car).then((res) => {
    response = res.data
  })
  return response;
}

